// 统一的api管理
import requests from "./request";
import requestsMock from "./mockRequest";

//三级联动接口
///api/product/ getBaseCategoryList get 无参数
//发请求：axios发请求返回结果Promise对象
export const reqCategoryList = () => requests.get('/product/getBaseCategoryList')

// mock请求轮播图bannerList数据
export const reqGetBannerList = () => requestsMock.get('/banner');
// mock请求轮播图floor数据
export const reqGetFloorList = () => requestsMock.get('/floor');

// 获取search模块的数据
// 需要用到参数，至少是一个空对象{}
export const reqGetSearchInfo = (params) => requests.post('/list', params)

// 获取Detail模块的数据
export const reqGetGoodInfo = skuId => requests.get(`/item/${skuId}`)

// 商品加入购物车时发送的请求 /api/cart/addToCart/{ skuId }/{ skuNum } post
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests.post(`/cart/addToCart/${skuId}/${skuNum}`)

// 请求购物车的数据
export const reqShopCart = () => requests.get('/cart/cartList')

// 8. 删除购物车商品 /api/cart/deleteCart/{skuId} DELETE
export const reqDeleteCart = (skuId) => requests.delete(`/cart/deleteCart/${skuId}`)

// 7. 切换商品选中状态 /api/cart/checkCart/{skuID}/{isChecked} GET
export const reqCheckCart = (skuId, isChecked) => requests.get(`/cart/checkCart/${skuId}/${isChecked}`)

// 13. 获取注册验证码 /api/user/passport/sendCode/phone get
export const reqGetVerificationCode = (phoneNumber) => requests.get(`/user/passport/sendCode/${phoneNumber}`)

// 12. 注册用户 /api/user/passport/register POST
export const reqRegister = (formData) => requests.post(`/user/passport/register`, formData)

// 9. 登录 /api/user/passport/login POST
export const reqUserLogin = (userData) => requests.post('/user/passport/login', userData)

// token获取用户信息
export const reqUserInfo = () => requests.get('/user/passport/auth/getUserInfo')

// 10. 退出登陆 /api/user/passport/logout GET
export const reqLogout = () => requests.get('/user/passport/logout')

// 15. 获取我的订单列表 /api/order/auth/{page}/{limit} GET
export const reqGetTradeList = (page, limit) => requests.get(`/order/auth/${page}/${limit}`)

// 获取用户地址信息 /api/user/userAddress/auth/findUserAddressList GET
export const reqUserAddress = () => requests.get('/user/userAddress/auth/findUserAddressList')

// 14. 获取订单交易页信息 /api/order/auth/trade GET
export const reqTradeInfo = () => requests.get('/order/auth/trade')

// 16. 提交订单 /api/order/auth/submitOrder?tradeNo={tradeNo} POST
export const reqSubmitOrder = (tradeNo, data) => requests.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, data)

// 17. 获取订单支付信息 /api/payment/weixin/createNative/{orderId} GET
export const reqGetPayInfo = (orderId) => requests.get(`/payment/weixin/createNative/${orderId}`)

// 18. 查询支付订单状态 /api/payment/weixin/queryPayStatus/{orderId} GET
export const reqGetPayStatus = (orderId) => requests.get(`/payment/weixin/queryPayStatus/${orderId}`)